package com.example.teesystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.teesystem.common.utils.Response;
import com.example.teesystem.entity.BoatRank;
import com.example.teesystem.entity.vo.boatGame.BoatRankResponse;
import com.example.teesystem.service.BoatRankService;
import com.example.teesystem.mapper.BoatRankMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 12510
* @description 针对表【t_boat_rank】的数据库操作Service实现
* @createDate 2022-11-26 12:48:03
*/
@Service
@RequiredArgsConstructor
public class BoatRankServiceImpl extends ServiceImpl<BoatRankMapper, BoatRank>
    implements BoatRankService{

    private final BoatRankMapper boatRankMapper;

    @Override
    public Response boatRank(int courseId) {
        List<BoatRank> boatRanks = boatRankMapper.getRank(courseId);
        List<BoatRankResponse> boatRankResponses = new ArrayList<>();
        for(BoatRank boatRank:boatRanks){
            boatRankResponses.add(new BoatRankResponse(boatRank));
        }
        return Response.ok(boatRankResponses);
    }
}




